// detail模块的小仓库
import { reqCityList, reqIdCityInfo,reqCityId } from "@/api"; //引入api里面的axios

const state = {
    cityList: [],
    detailCityInfo: []
};
const mutations = {
    GETCITYLIST(state, cityList) {
        state.cityList = cityList;
    },
    GETIDCITYLIST(state, detailCityInfo) {
        state.detailCityInfo = detailCityInfo
    }
};
const actions = {
    async getCityList({ commit }) {
        let result = await reqCityList();

        // console.log('result :>> ', result);
        if (result.code == 200) {
            commit("GETCITYLIST", result.data);
        }
    },
    async getIdCityList({ commit }, id) {
        let result = await reqIdCityInfo(id);

        console.log('result :>> ', result);
        if (result.code == 200) {
            commit("GETIDCITYLIST", result.data);
        }
    },
    async getCityId({ commit }, name) {
        let result = await reqCityId(name);

        console.log('result :>> ', result.data);
        if (result.code == 200) {
            return result
        }else {
            return result
        }
    },

};
const getters = {

};
export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters,
};